﻿Public Class ReglageImage

    Sub New()

        ' Cet appel est requis par le concepteur.
        InitializeComponent()

        ' Ajoutez une initialisation quelconque après l'appel InitializeComponent().
        Application.EnableVisualStyles()
    End Sub

    Private Sub btFermer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btFermer.Click
        Me.Close()
    End Sub

    Private Sub ckbActif_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ckbActif.CheckedChanged
        AjustVideoEnable = ckbActif.Checked
        tkbBrillance.Enabled = ckbActif.Checked
        tkbcontraste.Enabled = ckbActif.Checked
        tkbGamma.Enabled = ckbActif.Checked
        tkbSaturation.Enabled = ckbActif.Checked
        tkbTeinte.Enabled = ckbActif.Checked
    End Sub

    Private Sub tkbTeinte_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tkbTeinte.Scroll
        Hue = tkbTeinte.Value
    End Sub

    Private Sub tkbcontraste_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tkbcontraste.Scroll
        Contrast = tkbcontraste.Value / 100.0F
    End Sub

    Private Sub tkbBrillance_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tkbBrillance.Scroll
        Brightness = tkbBrillance.Value / 100.0F
    End Sub

    Private Sub tkbSaturation_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tkbSaturation.Scroll
        Saturation = tkbSaturation.Value / 100.0F
    End Sub

    Private Sub tkbGamma_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tkbGamma.Scroll
        Gamma = tkbGamma.Value / 100.0F
    End Sub

    Private Sub ReglageImage_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ckbActif.Checked = AjustVideoEnable
        tkbBrillance.Enabled = ckbActif.Checked
        tkbcontraste.Enabled = ckbActif.Checked
        tkbGamma.Enabled = ckbActif.Checked
        tkbSaturation.Enabled = ckbActif.Checked
        tkbTeinte.Enabled = ckbActif.Checked

        tkbTeinte.Value = Hue
        tkbcontraste.Value = CInt(Contrast * 100)
        tkbBrillance.Value = CInt(Brightness * 100)
        tkbSaturation.Value = CInt(Saturation * 100)
        tkbGamma.Value = CInt(Gamma * 100)

    End Sub

    Private Sub ckbHautBas_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ckbHautBas.CheckedChanged
        nudBottom.Enabled = Not (ckbHautBas.Checked)
    End Sub

    Private Sub ckbGaucheDroite_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ckbGaucheDroite.CheckedChanged
        nudRight.Enabled = Not (ckbGaucheDroite.Checked)
    End Sub

    Private Sub nud_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nudLeft.ValueChanged, nudBottom.ValueChanged, nudRight.ValueChanged, nudTop.ValueChanged
        Dim bas As String
        Dim droite As String
        If ckbGaucheDroite.Checked Then droite = nudLeft.Value.ToString Else droite = nudRight.Value.ToString
        If ckbHautBas.Checked Then bas = nudTop.Value.ToString Else bas = nudBottom.Value.ToString
        CropGeometry = nudLeft.Value.ToString & "+" & nudTop.Value.ToString & "+" & droite & "+" & bas

    End Sub
End Class